package file.day9_18.day03;

import java.io.*;

public class BOSCopyDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("fos.txt");
        BufferedInputStream bis = new BufferedInputStream(fis);//文档流到缓冲流
        FileOutputStream fos = new FileOutputStream("fos_cp.txt");
        BufferedOutputStream bos = new BufferedOutputStream(fos);//文档流到缓冲流
        int d;
        long start = System.currentTimeMillis();
        while ((d = bis.read()) != -1){//使用d直接接收读写到的内容
            bos.write(d);
        }

        //块写出
//        byte[] data = new byte[1024*100];
//        int len = bis.read(data);
//        bos.write(data);

        long end = System.currentTimeMillis();
        System.out.println("复制完成，耗时"+(end - start)+"ms");
        bos.close();//关闭高级流，与它连接的流也会关闭
        bis.close();//关闭高级流，与它连接的流也会关闭

    }
}
